package com.air.designmodel.three;

/**
 * 观察者模式测试类
 *
 * @author shent
 */
public class WeatherStation {
    public static void main(String[] args) {
        WeatherData weatherData = new WeatherData();
        //display在构造函数中,就把自己添加到了WeatherData的List集合中
        //当前信息
        CurrentConditionsDisplay currentConditionsDisplay = new CurrentConditionsDisplay(weatherData);
        //统计的平均温度,最高温度,最低温度信息
        StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherData);
        //在set方法中会通知各个 display 遍历显示出来数据
        weatherData.setMeasurements(80, 65, 30.4f);
        weatherData.setMeasurements(81, 70, 29.3f);

        statisticsDisplay.notObserver();
        weatherData.setMeasurements(78, 90, 29.2f);
        weatherData.setMeasurements(77, 90, 29.2f);
        statisticsDisplay.observer();
        weatherData.setMeasurements(75, 90, 29.2f);

    }
}
